package ee.karileet.ui.catalogue.view;

import com.vaadin.addon.touchkit.ui.NavigationButton;
import com.vaadin.addon.touchkit.ui.NavigationView;
import com.vaadin.addon.touchkit.ui.VerticalComponentGroup;
import com.vaadin.addon.touchkit.ui.NavigationButton.NavigationButtonClickEvent;
import com.vaadin.addon.touchkit.ui.NavigationButton.NavigationButtonClickListener;

import ee.karileet.productcatalogue.facade.IClientFacade;
import ee.karileet.productcatalogue.facade.impl.ClientFacade;
import ee.karileet.productcatalogue.model.Manufactor;
import ee.karileet.productcatalogue.model.Product;

@SuppressWarnings("serial")
public class ManufactorView extends NavigationView {
	private IClientFacade facade = new ClientFacade();
	public ManufactorView(Manufactor manufactor) {
        setCaption(manufactor.getName());
        
        final VerticalComponentGroup content = new VerticalComponentGroup();
        NavigationButton button = null;
        for (final Product p : facade.listProductsByManufactor(manufactor.getId())) {
			button = new NavigationButton(p.getName());
	        button.addClickListener(new NavigationButtonClickListener() {
	            @Override
	            public void buttonClick(NavigationButtonClickEvent event) {
	                getNavigationManager().navigateTo(new ProductView(p));                
	            }
	        });
	        content.addComponent(button);
        }
        setContent(content);
        
    };

}
